package com.sx.gongzhong.pest;

import android.content.Context;

import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.model.WebListItemBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.model.BasePageListBean;
import com.sx.gongzhong.view.WebListView;

import java.util.HashMap;
import java.util.Map;

/**获取 便民公告 办事指南 平安宣传
 * Created by admin on 2018/1/3.
 */

public class WebListPest {
    private WebListView convenniceAnnounceView;

    public WebListPest(WebListView convenniceAnnounceView) {
        this.convenniceAnnounceView = convenniceAnnounceView;
    }
    //获取 便民公告
    public void getConvenniceAnnounceData(Context context, int page, int rows) {
        Map<String,Object> map = new HashMap<>();
        map.put("sourcesState",0);
        map.put("page",page);
        map.put("rows",rows);
        new ApiManager().getConvenniceAnnounceData(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<WebListItemBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<WebListItemBean>> response) {
                convenniceAnnounceView.getSuccess(response.data.rows,response.data.total);
            }
            @Override
            public void onFailures(String message) {
                convenniceAnnounceView.showError(message);
            }
        });
    }
    //获取 办事指南
    public void getGuidanceData(Context context, int page, int rows) {
        Map<String,Object> map = new HashMap<>();
        map.put("sourcesState",0);
        map.put("page",page);
        map.put("rows",rows);
        new ApiManager().getGuidanceData(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<WebListItemBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<WebListItemBean>> response) {
                convenniceAnnounceView.getSuccess(response.data.rows,response.data.total);
            }
            @Override
            public void onFailures(String message) {
                convenniceAnnounceView.showError(message);
            }
        });
    }
    //获取 平安宣传
    public void getPromotePeaceData(Context context, int page, int rows) {
        Map<String,Object> map = new HashMap<>();
        map.put("sourcesState",0);
        map.put("page",page);
        map.put("rows",rows);
        new ApiManager().getPromotePeaceData(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<WebListItemBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<WebListItemBean>> response) {
                convenniceAnnounceView.getSuccess(response.data.rows,response.data.total);
            }
            @Override
            public void onFailures(String message) {
                convenniceAnnounceView.showError(message);
            }
        });
    }
}
